package com.hiultra.archive.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hiultra.common.annotation.Log;
import com.hiultra.common.core.controller.BaseController;
import com.hiultra.common.core.domain.AjaxResult;
import com.hiultra.common.enums.BusinessType;
import com.hiultra.archive.domain.ArcAppraialDetails;
import com.hiultra.archive.service.IArcAppraialDetailsService;
import com.hiultra.common.utils.poi.ExcelUtil;
import com.hiultra.common.core.page.TableDataInfo;

/**
 * 鉴定详情Controller
 * 
 * @author ls
 * @date 2023-08-31
 */
@RestController
@RequestMapping("/archive/details")
public class ArcAppraialDetailsController extends BaseController
{
    @Autowired
    private IArcAppraialDetailsService arcAppraialDetailsService;

    /**
     * 查询鉴定详情列表
     */
    @PreAuthorize("@ss.hasPermi('archive:details:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArcAppraialDetails arcAppraialDetails)
    {
        startPage();
        List<ArcAppraialDetails> list = arcAppraialDetailsService.selectArcAppraialDetailsList(arcAppraialDetails);
        return getDataTable(list);
    }

    /**
     * 导出鉴定详情列表
     */
    @PreAuthorize("@ss.hasPermi('archive:details:export')")
    @Log(title = "鉴定详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArcAppraialDetails arcAppraialDetails)
    {
        List<ArcAppraialDetails> list = arcAppraialDetailsService.selectArcAppraialDetailsList(arcAppraialDetails);
        ExcelUtil<ArcAppraialDetails> util = new ExcelUtil<ArcAppraialDetails>(ArcAppraialDetails.class);
        util.exportExcel(response, list, "鉴定详情数据");
    }

    /**
     * 获取鉴定详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive:details:query')")
    @GetMapping(value = "/{appraisalDetailId}")
    public AjaxResult getInfo(@PathVariable("appraisalDetailId") Long appraisalDetailId)
    {
        return AjaxResult.success(arcAppraialDetailsService.selectArcAppraialDetailsByAppraisalDetailId(appraisalDetailId));
    }

    /**
     * 新增鉴定详情
     */
    @PreAuthorize("@ss.hasPermi('archive:details:add')")
    @Log(title = "鉴定详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArcAppraialDetails arcAppraialDetails)
    {
        return toAjax(arcAppraialDetailsService.insertArcAppraialDetails(arcAppraialDetails));
    }

    /**
     * 修改鉴定详情
     */
    @PreAuthorize("@ss.hasPermi('archive:details:edit')")
    @Log(title = "鉴定详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArcAppraialDetails arcAppraialDetails)
    {
        return toAjax(arcAppraialDetailsService.updateArcAppraialDetails(arcAppraialDetails));
    }

    /**
     * 删除鉴定详情
     */
    @PreAuthorize("@ss.hasPermi('archive:details:remove')")
    @Log(title = "鉴定详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{appraisalDetailIds}")
    public AjaxResult remove(@PathVariable Long[] appraisalDetailIds)
    {
        return toAjax(arcAppraialDetailsService.deleteArcAppraialDetailsByAppraisalDetailIds(appraisalDetailIds));
    }
}
